package com.liuwei.controller;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.liuwei.common.EasyuiModel;
import com.liuwei.model.RpTransactionMessage;
import com.liuwei.service.RpTransactionMessageService;

@RestController
@RequestMapping(value = "/message")
public class MessageController {
	@Resource
	private RpTransactionMessageService messageService;

	@PostMapping(value = "save ")
	public RpTransactionMessage save(RpTransactionMessage r) {
		r.setCreateTime(new Date());
		RpTransactionMessage save = messageService.save(r);
		return save;
	}

	@GetMapping(value = "list")
	public EasyuiModel<RpTransactionMessage> list() {
		Page<RpTransactionMessage> result = messageService.findAll();
		return new EasyuiModel<RpTransactionMessage>(result.getNumber() + 1, result.getSize(), result.getContent(),
				result.getTotalPages(), result.getNumber(), result.getTotalElements());
	}

}
